﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class FlightController
{
    private Airplane owner;
    private bool isLRB; //是否启用z轴平衡(左右)
    private bool isUDB; //是否启用x轴平衡(上下)

    public void Initialize(Airplane owner)
    {
        this.owner = owner;
    }

    public void MoveFB(float speed)
    {
        owner.rBody.AddRelativeForce(Vector3.forward * owner.moveFBSpeed * speed);
    }
    
    public void MoveLR(float speed)
    {
        owner.rBody.AddRelativeForce(Vector3.left * owner.moveLRSpeed * speed);
    }

    public void RoteUD(float speed)
    {
        isUDB = false;
        owner.rBody.AddRelativeTorque(Vector3.left * owner.rotaUDSpeed * speed);
        
    }

    public void RoteLR(float speed)
    {
        isLRB = false;
        owner.rBody.AddRelativeTorque(Vector3.forward * owner.rotaLRSpeed * speed);
        //owner.rBody.AddForceAtPosition()
    }

    public void Balance()
    {
        if(isLRB)
        {

        }
        
        if(isUDB)
        {

        }

        isLRB = true;
        isUDB = true;
    }
}
